﻿using System.Drawing;

namespace Multivee.UI
{
    /// <summary>
    /// This is the business object we will use to store screen configurations.
    /// </summary>
    public class ScreenViewConfiguration
    {
        private Image _thumbNail = null;
        /// <summary>
        /// The name specified by the user for this configuration.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// The tile that will be used as the source for the view's pattern.
        /// </summary>
        public Image Tile { get; set; }

        /// <summary>
        ///  The zero-based screen index in which to display this tile pattern.
        /// </summary>
        public int ScreenIndex { get; set; }

        /// <summary>
        /// The number of tiles to display accross the horizontal plane in the screen view.
        /// </summary>
        public float TileDensity { get; set; }

        /// <summary>
        /// First we calculate spacing, then we fill what's left with the number of tiles specified in TileDensity.
        /// </summary>
        public float SpacingAsPercentage { get; set; }

        public Size ScreenSize { get; set; }

        public Image Thumbnail 
        {
            get
            {
                if (_thumbNail == null && Tile != null)
                {
                    Bitmap fullImage = ScreenViewController.MakeMosaic(this);
                    int w = fullImage.Width / 5;
                    int h = fullImage.Height / 5;
                    _thumbNail = new Bitmap(fullImage, new Size(w, h));
                    fullImage.Dispose();
                }
                
                return _thumbNail;
            }
            set
            {
                _thumbNail = value;
            }
        }
    }
}
